//
//  BKUserThirdLoginMannager.m
//  bestkeep
//
//  Created by windCould on 16/12/29.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKUserThirdLoginMannager.h"

@implementation BKUserThirdLoginMannager

+(void)getUserInfoForPlatform:(NSString *)platform result:(BKUserThirdLoginCompleteBlock)resultBlock
{
    
    UMSocialPlatformType Type;
    if ([platform isEqualToString:@"wechat"]) {
        
        Type = UMSocialPlatformType_WechatSession;
    } else {
    
        Type = UMSocialPlatformType_QQ;
    }

    [[UMSocialManager defaultManager] getUserInfoWithPlatform:Type currentViewController:nil completion:^(UMSocialUserInfoResponse * result, NSError *error) {
        
        UMSocialUserInfoResponse *resp = result;
        
        // 第三方登录数据(为空表示平台未提供)
        // 授权数据
        NSLog(@" uid: %@", resp.uid);
        NSLog(@" openid: %@", resp.openid);
        NSLog(@" accessToken: %@", resp.accessToken);
        NSLog(@" refreshToken: %@", resp.refreshToken);
        NSLog(@" expiration: %@", resp.expiration);
        
        // 用户数据
        NSLog(@" name: %@", resp.name);
        NSLog(@" iconurl: %@", resp.iconurl);
        NSLog(@" gender: %@", resp.gender);
        
        // 第三方平台SDK原始数据
        NSLog(@" originalResponse: %@", resp.originalResponse);
        
        resultBlock(resp,error);
    }];

}

//判断是否在本地
+(BOOL)isInChina
{
    BOOL result = NO;
    NSLog(@"----->%@",[[NSTimeZone localTimeZone] name]);
    if([[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Chongqing"].location == 0 ||
       [[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Harbin"].location == 0 ||
       [[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Hong_Kong"].location == 0 ||
       [[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Macau"].location == 0 ||
       [[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Shanghai"].location == 0 ||
       [[[NSTimeZone localTimeZone] name] rangeOfString:@"Asia/Taipei"].location == 0)
    {
        result = YES;
    }
    
    return result;
}




@end
